/*
 *超时标本自动提醒
 */

<template>
    <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=35 :canDrag=false>
        <template v-slot:fix>
            <div style="height:35px;border:1px solid #CCC;padding:4px">
                <el-row>
                    <el-col :span="14">
                        <div class="grid-content bg-purple"> <span class="remind_class">以下报告已经超时或者接近超时，请优先处理！！</span></div>
                    </el-col>

                    <el-col :span="10">
                        <div class="grid-content bg-purple-light">
                            <el-button style="width:72px" @click.native="btnRefresh">刷新</el-button>
                            <el-button style="width:72px" @click.native="btnRptdelay">报告延迟</el-button>
                            <el-button style="width:72px" @click.native="btnClose">退出</el-button>
                        </div>
                    </el-col>

                </el-row>
            </div>
        </template>
        <div style="height:100%">
            <vxe-table show-overflow ref="xTable" :data.sync="timeoutRptData" height="auto" width="100%" border size="mini" :select-config="{ reserve: true }" show-header-overflow resizable header-align="center" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" key="1" :row-class-name="rowclassname" class="mytable-style" @current-change="currentChangeEvent" :loading="loading">
                <vxe-table-column type="selection" width="50" align="center">
                </vxe-table-column>
                <vxe-table-column field="rptunitid" title="报告单元" width="120">
                    <template v-slot="{row}">
                        <div>{{row.rptunitname}}</div>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="sampledate" title="标本日期" width="90" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                <vxe-table-column field="sampleno" title="标本号" width="70"></vxe-table-column>
                <vxe-table-column field="emer_flag" title="加急" width="50" align="center">
                    <template v-slot="{row}">
                        <div>{{row.emer_flag=='1'?'急':''}}</div>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="recieve_dt" title="接收时间" width="120" align="center"></vxe-table-column>
                <vxe-table-column field="prereport_dt" title="预出报告时间" width="120" align="center"></vxe-table-column>
                <vxe-table-column field="pat_name" title="姓名" width="60"></vxe-table-column>
                <vxe-table-column field="req_reason" title="送检目的" width="100"></vxe-table-column>
                <vxe-table-column field="req_deptname" title="申请科室" width="100"></vxe-table-column>
                <vxe-table-column field="req_bedno" title="床号" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="req_wardname" title="病区" width="100"></vxe-table-column>
                <vxe-table-column field="specimen_name" title="标本类型" width="100"></vxe-table-column>
                <vxe-table-column field="pat_no" title="病人号" width="80"></vxe-table-column>
                <vxe-table-column field="barcode" title="条码号" width="120"></vxe-table-column>
                <vxe-table-column field="req_docname" title="申请医生" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="req_dt" title="申请时间" width="120" align="center"></vxe-table-column>
                <vxe-table-column field="hospname" title="送检医院" width="90" align="center"></vxe-table-column>
                <vxe-table-column field="sampled_dt" title="采样时间" width="120" align="center"></vxe-table-column>
                <vxe-table-column field="sampled_username" title="采样人" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="input_dt" title="录入时间" width="120">
                </vxe-table-column>
                <vxe-table-column field="reportid" title="报告ID" width="120" align="center"></vxe-table-column>
                <!-- <template v-slot:fix>
                    <div style="font-size:17px;padding-top:3px;background-color:#fff;text-align:center;font-weight:bold;color:blue">共 {{datacnt}} 条</div>
                </template> -->
            </vxe-table>
        </div>

        <el-dialog title="报告延时发放" :visible.sync="dialogRptDelay" width="580px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" ref="refdialogRptDelay">
            <rm-rptdelay :barcodes="delay.barcodes" ref="refrptdelay" :key="delay.delaykey" @change="RptDelayChange"></rm-rptdelay>
        </el-dialog>
    </rm-layout-top>

</template>

<script type="text/javascript">
export default {
    name: "rm_rpttimeoutalertinfo",
    props: {
        tabledata: { type: Array },
        params: { type: Object },
    },
    data() {
        return {
            timeoutRptData: this.tabledata,
            loading: false,
            delay: { barcodes: "", delaykey: 0 },
            dialogRptDelay: false,
        };
    },
    created() {
        //console.log("121", this.tabledata);
    },
    computed: {
        // datacnt() {
        //     if (!!this.tabledata) return this.tabledata.length;
        //     else return 0;
        // },
    },
    watch: {},
    mounted() {},
    methods: {
        //获取自动提醒弹窗的选中行
        currentChangeEvent({ row, column }) {},
        //自动提醒弹窗列表的颜色
        rowclassname({ row, column }) {
            return "row-pink";
        },
        //报告延迟
        btnRptdelay() {
            let data = this.$refs.xTable.getSelectRecords();
            if (data.length == 0) {
                this.$alert("请勾选要延迟报告的标本！", "提示");
                return false;
            } else {
                this.delay.barcodes = "";
                data.forEach((item) => {
                    this.delay.barcodes += item.barcode + ",";
                });
                this.delay.delaykey++;
                this.dialogRptDelay = true;
            }
        },
        //报告延迟确认返回
        RptDelayChange(flag, msg) {
            if (flag == "1") {
                this.$alert("更新成功，共计更新" + msg + "条数据！", "提示").then(() => {
                    this.btnRefresh();
                    this.dialogRptDelay = false;
                });
            } else if (flag == "close") {
                this.dialogRptDelay = false;
            } else {
                this.$alert(msg, "提示");
            }
        },
        //刷新超时报告
        btnRefresh() {
            this.loading = true;
            this.$tool
                .request({
                    url: "ucent/alertmsg",
                    method: "post",
                    data: {
                        params: this.params.paramlist,
                    },
                })
                .then((res) => {
                    this.timeoutRptData = res.data;
                    this.loading = false;
                })
                .catch((e) => {
                    this.$alert(e, "提示");
                    this.loading = false;
                });
        },
        //退出
        btnClose() {
            this.$emit("change", "close");
        },
    },
};
</Script>

<style scoped>
.remind_class {
    color: rgb(236, 11, 11);
    font-size: 18px;
}
::v-deep .mytable-style .vxe-body--row.row-pink {
    background-color: pink;
    color: rgb(8, 8, 8);
}
</style>
